/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.proxy.component
{
	import mx.controls.Alert;
	
	/**
	 * HTTPService 调用成功返回结果 
	 * 
	 */	
	public class HttpProxyResult
	{
		private var poList:Array;
		private var index:int=-1;
		private var _state:String;
		private var poResult:PoResult;
		
		/**
		 * 构造HTTPService 调用成功返回结果 
		 * 
		 */		
		public function HttpProxyResult()
		{
			poList=new Array();
		} 
		
		/**
		 * 添加 PoResult 到该返回集中。
		 * @param value PoResult 对象
		 * 
		 */		
		public function addPOResult(value:PoResult):void
		{
			poList.push(value);
		}
		
		/**
		 * 返回返回结果记得长度， 
		 * @return 
		 * 
		 */		
		public function get poResultLenght():int{return poList.length;}
		
		/**
		 * 返回集指针下移以为。 
		 * @return 
		 * 
		 */		
		public function poNext():Boolean
		{
			if(index<poList.length-1){
				index++;
				poResult=poList[index] as PoResult;
				return true;
			}else{
				index=-1;
				poResult=null;
				return false;
			}
		}
		
		/**
		 * 根据提交时的dsName查找到对应的PoResult对象。 
		 * @param dsName dsName名称
		 * @return  PoResult对象
		 * 
		 */		
		public function getPoResultByDsName(dsName:String):PoResult{
			var poResult:PoResult;
			for(var i:int;i<poList.length;i++){
				poResult = poList[i] as PoResult;
				if (poResult.dsName == dsName){
					break;
				}
			}
			return poResult;
		}
		
		/**
		 * 返回到第一个 PoResult对向处。
		 * 
		 */		
		public function poReset():void{index=0;poResult=poList[index] as PoResult;}
		
		/**
		 * 总的返回状态 
		 * @param value
		 * 
		 */		
		public function set state(value:String):void{_state=value;}
		public function get state():String{return _state;}
		
		/**
		 * 返回当前的 poResult 对象 
		 * @return poResult 对象
		 * 
		 */		
		public function get currentPoResult():PoResult{return poResult;}
		
		/**
		 * 返回所有 poResult 集合。
		 * @return 
		 * 
		 */		
		public function get poResultList():Array {return poList;}
	}
}